package problema050;

public class ConsecutivePrimeSum {
	
	static boolean[] isPrime;
	static int cant = 0;
	static int res = 0;

	
	public static void main(String[] args){
		sieveOfEratosthenes(1000000);
		System.out.println(primeSum() + " " + cant);
	}
	
	public static int primeSum(){
		for(int i = 0; i < 1000000; i++){
			if(isPrime[i]){
				System.out.println(i);
				sePuede(i);
			}
		}
		return res;
	}
	
	public static boolean sePuede(int n){
		int acum = 0, act = 0;
		for(int i = 1; i < n; i++){
			if(!isPrime[i]) continue;
			for(int j = i; j < n; j++){
				if(!isPrime[j]) continue;
				act++;
				acum += j;
				if(acum > n) break;
				if(acum == n){
					if(act > cant){
						cant = act;
						res = n;
					}
					return true;
				}
			}
			act = 0;
			acum = 0;
		}
		return false;
	}
	
	
	public static void sieveOfEratosthenes(int n){
	     isPrime = new boolean[n + 1];
	     for (int i = 2; i <= n; i++) {
	         isPrime[i] = true;
	     }
	     for (int i = 2; i*i <= n; i++) {
	         if (isPrime[i]) {
	             for (int j = i; i*j <= n; j++) {
	                 isPrime[i*j] = false;
	             }
	         }
	     }
	 }

}
